package com.film.controller.movie;

import com.alibaba.fastjson.JSONObject;
import com.film.jwt.JwtUtil;
import com.film.service.impl.movie.DeleteMovieCommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

@RestController
public class DeleteMovieCommentController {
    @Autowired
    private DeleteMovieCommentServiceImpl deleteMovieCommentService;

    @PostMapping("/movieComment/delete")
    public JSONObject delete(@RequestParam (value = "movieId") Integer movie_id,
                             @RequestParam (value = "commentatorId") Integer commentator_id,
                             @RequestParam (value = "token") String token)
                        throws SQLException {
        if (!JwtUtil.JwtVerify(token)) {
            JSONObject resp = new JSONObject();
            resp.put("error_message", "jwt验证错误");
            return resp;
        } else {
            return deleteMovieCommentService.delete(movie_id,commentator_id);
        }
    }
}
